/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


var fieldLabel = new Array('单位', '超期', '即将到期', '超期', '即将到期', '超期', '即将到期', '超期', '即将到期', '超期', '即将到期');
var fieldLabel1 = new Array('A类', 'B类', 'C类', 'D类', '合计');
var fieldName = new Array('orgName', 'acq', 'ajjdq', 'bcq', 'bjjdq', 'ccq', 'cjjdq', 'dcq', 'djjdq', 'allcq', 'alljjdq');
var _pageSize = 20;
var record_start = 0;


var daysStore = new Ext.data.SimpleStore({
    fields: ["days"],
    data: [[7],[15],[30],[90],[120]]
});

var daysCombo = {
    name: 'days',
    id: 'Days',
    xtype: 'combo',    
    width: 100,
    triggerAction: 'all',    
    hiddenName: 'days',
    editable: true,
    store: daysStore,
    displayField: 'days',
    valueField: 'days',
    value:7,
    mode: 'local',    
    listeners: {
        select: function(combo, record, index) {
            store.baseParams.days = combo.getValue();
        }
    }
};



var store = new Ext.data.JsonStore({    
    url: "../../servlet/system/PointLoad",
    root: 'data',
    idProperty: 'id',
    totalProperty: 'count',
    fields: fieldName,
    autoLoad: true,
    baseParams:{cmd:"checkSummary",days:7,reportStatus:-1,range:-1}
});

var now = new Date();

var colModel = new Ext.grid.ColumnModel({
    columns: [
        new Ext.grid.RowNumberer({
            header: '序号',
            align: 'center',
            width: 40,
            renderer: function(value, metadata, record, rowIndex) {
                return record_start + 1 + rowIndex;
            }
        }),
        {
            header: fieldLabel[0],
            width: 100,
            dataIndex: fieldName[0],
            align: 'center'
        },
        {
            header: fieldLabel[1],
            width: 100,
            dataIndex: fieldName[1],
            align: 'center'
        },
        {
            header: fieldLabel[2],
            width: 100,
            dataIndex: fieldName[2],
            align: 'center'
        },
        {
            header: fieldLabel[3],
            width: 100,
            dataIndex: fieldName[3],
            align: 'center'
        },
        {
            header: fieldLabel[4],
            width: 100,
            dataIndex: fieldName[4],
            align: 'center'
        },
        {
            header: fieldLabel[5],
            width: 100,
            dataIndex: fieldName[5],
            align: 'center'
        },
        {
            header: fieldLabel[6],
            width: 100,
            dataIndex: fieldName[6],
            align: 'center'
        },
        {
            header: fieldLabel[7],
            width: 100,
            dataIndex: fieldName[7],
            align: 'center'
        },
        {
            header: fieldLabel[8],
            width: 100,
            dataIndex: fieldName[8],
            align: 'center'
        },
        {
            header: fieldLabel[9],
            width: 100,
            dataIndex: fieldName[9],
            align: 'center'
        },
        {
            header: fieldLabel[10],
            width: 100,
            dataIndex: fieldName[10],
            align: 'center'
        }
    ],
    defaultSortable: true,
    rows: [
        [
            {
                width: 100,
                rowspan: 1
            },
            {
                width: 100,
                rowspan: 1
            },
            {
                width: 100,
                header: fieldLabel1[0],
                colspan: 2,
                align: 'center'
            },
            {
                width: 100,
                header: fieldLabel1[1],
                colspan: 2,
                align: 'center'
            },
            {
                width: 100,
                header: fieldLabel1[2],
                colspan: 2,
                align: 'center'
            },
            {
                width: 100,
                header: fieldLabel1[3],
                colspan: 2,
                align: 'center'
            },
            {
                width: 100,
                header: fieldLabel1[4],
                colspan: 2,
                align: 'center'
            }
        ]
    ]
});

var grid = new Ext.grid.GridPanel({
    title: currentOrgName + ' 装置超期未校验告警',
    store: store,
    colModel: colModel,
    enableColumnMove: false,
    viewConfig: {
        forceFit: true
    },
    plugins: [new Ext.ux.plugins.GroupHeaderGrid()],
    loadMask: true,
    tbar: new Ext.Toolbar([
        rangeCombo,
        reportCombo,
        "-",
        {xtype:'label',text:'设定即将到期时间'},
        daysCombo,
        {
            xtype: 'button',
            text: '搜索',
            iconCls: 'icon-search',
            width: 60,
            style: {marginLeft: '20px'},
            handler: function() {
                store.load({params: {start: 0, limit: _pageSize}});
            }
        }
    ]),
    bbar: new Ext.PagingToolbar({
        pageSize: _pageSize,
        store: store,
        displayInfo: true,
        displayMsg: '显示记录：{0} - {1}   总记录：{2}',
        emptyMsg: '目前没有信息'
    })
});
store.load({
    params: {
        start: 0,
        limit: _pageSize
    }
});






function buildWindow() {
    var applicationUI = new Ext.Viewport({
        layout: 'fit',
        items: [
            grid
        ]
    });
}
Ext.onReady(buildWindow); 